﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!--引用CW标签  -->
<%@ taglib prefix="CW" uri="/WEB-INF/taglib/cw" %>
<!--引用struts标签  -->
<%@ taglib prefix="s" uri="/struts-tags" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <title>分配账号</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <script type="text/javascript" src="<%=basePath%>js/commons/common_edit.js"></script>
    <link href="<%=basePath%>css/en/edit.css" rel="stylesheet" type="text/css">
    <script type="text/javascript">
    $(document).ready(
   		function() {
   			$('#addForm').validate(
   			{
   				rules : {
   					"userInfo.UserName":{required : true },
   				}
   		});
   	});  
    
    function __back(){
	 	var _url = "<%=basePath%>/user/getAllUser.action";
		location.href=_url;
	}
    function __submit(){
    	if($("#addForm").valid()){
	    	var userName=$("#UserName").val();
	    	if(userName.length>13||userName.length<3){
	    		art.dialog.tips('账户长度需要设置为3位到13位之间字符！');
	    		return;
	    	}
	    	$.ajax({  
	    		type: "post",  
			    async: false,
			    url: "<%=basePath%>/userAjax/validateUser.action",  
			    data: {                     //要传递的数据
			        "UserName": userName
				 }, 
				 success: function(data){ 
	 		    	if(data.toString()=='false'){//重复
	 				    art.dialog.alert('该用户名已经存在，请重新输入');
	 				    return;
	 		    	}else if(data.toString()=='true'){//未重复
	 		    		 
	 		       		$("#loadingdiv").show();
	 		   	    		document.addForm.action="<%=basePath%>user/addUserAccount.action";
	 		   	    		document.addForm.submit();
	 		    	}else{
	 		    		//art.dialog.tips('新增用户成功');
	 		    	}
	 		    }
	    	});
    	}
	}
    function __refresh(){
       location.reload();
    }
    
    //回车操作
    var SubmitOrHidden = function(evt){
        evt = window.event || evt;
        if(evt.keyCode==13){
        	__submit();      
         }
    };
    window.document.onkeydown=SubmitOrHidden;
    </script>
</head>
  
<body>
<form action="user/addUserAccount.action" name="addForm" id="addForm" method="post" target="mainFrame">
<div class="pageheader">
	<div class="pagetitle">
	   快速注册
	</div>
	<!-- 操作按钮 -->
	<div class="pageheadercontent">
		<div class="toolbar">
			<div class="toolbarright">
				<input class="okbtn" name="_submit" type="button" value="OK" onclick="__submit()">
				<input class="calbtn" name="_back" type="button" value="Cancel" onclick="__back()">
			</div>
		</div>
	</div>
</div>

<div class="writetblbox" style="width: 700px">
	<table class="writetbl" style="width: 100%">
	  <tr><th>账号:</th><td><input type="text" id="UserName" name="userInfo.UserName"  value="" onchange="_validateUserName()"/></td></tr>
      <tr><th>账号状态:</th>
      <td><select  name="userInfo.Status" id="userInfoStatus">
      		 <option value="1" selected = "selected">启动</option>
      		 <option value="0" >禁用</option>
          </select></td></tr>
	</table>
</div>
</form>
</body>
</html>
